package cn.melonlib.cores.commons.comp.utils.filter;


import cn.melonlib.objects.maps.JsonMap;

import java.util.List;

/**
 * 筛选条件组装
 */
public class QlFilters {

    private JsonMap<JsonMap<Object>> conditionsMap=JsonMap.createMap();

    public QlFilters addEq(String name,Object value){
        this.conditionsMap.append(name,JsonMap.createMap().append("eq",value));
        return this;
    }

    public QlFilters addUeq(String name,Object value){
        this.conditionsMap.append(name,JsonMap.createMap().append("ueq",value));
        return this;
    }

    public QlFilters addLike(String name,Object value){
        this.conditionsMap.append(name,JsonMap.createMap().append("like",value));
        return this;
    }

    public QlFilters addGt(String name,Object value){
        this.conditionsMap.append(name,JsonMap.createMap().append("gt",value));
        return this;
    }

    public QlFilters addLt(String name,Object value){
        this.conditionsMap.append(name,JsonMap.createMap().append("lt",value));
        return this;
    }

    public QlFilters addGte(String name,Object value){
        this.conditionsMap.append(name,JsonMap.createMap().append("gte",value));
        return this;
    }

    public QlFilters addLte(String name,Object value){
        this.conditionsMap.append(name,JsonMap.createMap().append("lte",value));
        return this;
    }

    public QlFilters addIn(String name, List<? extends Object> items){
        this.conditionsMap.append(name,JsonMap.createMap().append("in",items));
        return this;
    }

    public QlFilters addNin(String name, List<?extends Object> items){
        this.conditionsMap.append(name,JsonMap.createMap().append("uin",items));
        return this;
    }
    public JsonMap<JsonMap<Object>> getConditionsMap(){
        return this.conditionsMap;
    }
}
